package com.wocao.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wocao.entity.ReqBody;
import com.wocao.entity.ResponseResult;
import com.wocao.entity.ZyCommunity;
import com.wocao.entity.ZyComplaintSuggest;
import com.wocao.service.ZyCommunityService;
import com.wocao.service.ZyComplaintSuggestService;
import com.wocao.utils.OssUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * <p>
 * 投诉建议  前端控制器
 * </p>
 *
 * @author cwj
 * @since 2023-11-29
 */
@CrossOrigin
@RestController
@RequestMapping("zyComplaintSuggest")
public class ZyComplaintSuggestController {

    @Autowired
    private ZyComplaintSuggestService zyComplaintSuggestService;

    @PostMapping("/selectComplaintAllPage/{page}")
    public ResponseResult selectComplaintAllPage(@PathVariable int page, @RequestBody ReqBody reqBody){
        Page<ZyComplaintSuggest> zyComplaintSuggestPage = zyComplaintSuggestService.selectComplaintAll(new Page(page, reqBody.getSize()), reqBody);
        return ResponseResult.ok(zyComplaintSuggestPage);
    }

    //导出
    @GetMapping("/derive")
    public void derive(HttpServletResponse response, @RequestParam("complaintIds") String[] complaintIds) throws IOException {
        zyComplaintSuggestService.derive(response,complaintIds);
    }

    //更新投诉状态
    @PutMapping("editComplaintStatus")
    public ResponseResult editComplaintStatus(@RequestParam("comId") String comId){
        zyComplaintSuggestService.editComplaintStatus(comId);
        return ResponseResult.ok("已读");
    }

}
